package com.webex.ta.hydra.gui.action;

import com.webex.ta.hydra.gui.AboutDialog;
import com.webex.ta.hydra.gui.GuiPackage;
import com.webex.ta.hydra.util.HydraUtils;
import org.eclipse.swt.SWT;
import org.eclipse.swt.browser.Browser;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

import java.awt.event.ActionEvent;
import java.util.HashSet;
import java.util.Set;

/**
 * Created by Cisco WebEx.
 * User: vegaz
 * Date: 2010-9-9
 * Time: 17:06:02
 */
public class AboutAction implements ActionHandler {
    private static Set<String> commands = new HashSet<String>();

    static {
        commands.add(ActionNames.ABOUT);
    }

    public Set<String> getActionNames() {
        return commands;
    }

    public void doAction(ActionEvent e) {
        AboutDialog ad = new AboutDialog(GuiPackage.getInstance().getIdeFrame());
//        Thread t = new Thread(new ViewReportThread());
//        t.start();
    }

    private class ViewReportThread implements Runnable {
        public void run() {
            Display display = Display.getDefault();
            final Shell shell = new Shell(display);
            shell.setText("View report");
//            shell.setImage(HydraUtils.getImage("hydra.jpg"));
            shell.setSize(700, 500);
            shell.setLayout(new FillLayout());

            Browser b = new Browser(shell, SWT.BORDER);
            b.setUrl("http://www.baidu.com");
            shell.open();
            while (!shell.isDisposed()) {
                try {
                    if (!display.readAndDispatch())
                        display.sleep();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
            display.dispose();
        }
    }
}
